package com.blogs.component;

import java.util.ArrayList;

import com.blogs.entity.FavFeed;
import com.blogs.entity.Feed;
import com.blogs.tools.DBSharedPreferences;
import com.blogs.tools.FormatTime;
import com.cnblogs.R;
import com.cnblogs.R.color;


import android.app.Activity;
import android.graphics.Color;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class FavoAdapter extends BaseAdapter{
	private  ArrayList<FavFeed> feedList = null;
	private ViewHolder holder;
	private Activity context = null;
//	private DBSharedPreferences sp;
	public FavoAdapter(Activity context, ArrayList<FavFeed> feedList)
	{
		this.context = context;
		this.feedList = feedList;
//		sp= new DBSharedPreferences(context);
	}
	public int getCount() {
		// TODO Auto-generated method stub
		return feedList.size();
	}
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return feedList.get(position);
	}
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null ) {
			convertView = View.inflate(context, R.layout.favorite_adapter_template,null);
			holder=new ViewHolder();
			holder.favorite_title=(TextView)convertView.findViewById(R.id.favorite_title);
			holder.fav_time_tv=(TextView)convertView.findViewById(R.id.fav_time_tv);
			convertView.setTag(holder);
		}
	    else
	    {
	    	holder = (ViewHolder) convertView.getTag();
	    }
		holder.favorite_title.setText(feedList.get(position).title);
		holder.fav_time_tv.setText(FormatTime.format(feedList.get(position).favo_time));
		return convertView;
	}
	
	class ViewHolder 
	{
		TextView favorite_title;
		TextView fav_time_tv;
	}
}
